﻿using Microsoft.Data.Sqlite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Notes.Services
{
    internal class DatebaseService
    {
        public void Connect()
        {
            string connectionString = "Data Source=your_database.db";
            using (var connection = new SqliteConnection(connectionString))
            {
                connection.Open();
                // 在此处执行数据库操作

                // 插入、更新和删除数据
                string insertSql = "INSERT INTO your_table (column1, column2) VALUES (@value1, @value2)";
                using (var command = new SqliteCommand(insertSql, connection))
                {
                    command.Parameters.AddWithValue("@value1", "some_value");
                    command.Parameters.AddWithValue("@value2", 123);
                    command.ExecuteNonQuery();
                }

                // 执行查询
                using (var command = new SqliteCommand("SELECT * FROM your_table", connection))
                {
                    using (SqliteDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Console.WriteLine(reader["column_name"]);
                        }
                    }
                }
            }
        }

    }
}
